#include "loginrequestmessage.h"

#include <QJsonObject>

LoginRequestMessage::LoginRequestMessage(const UserId& userId, const Password& password)
{
    m_messageType = MessageType::LoginRequest;
    m_userId = userId;
    m_password = password;
}
LoginRequestMessage::LoginRequestMessage(const QJsonObject& jsonObj)
{
    m_messageType = static_cast<MessageType>(jsonObj[JsonKey::TYPE].toInt());
    m_userId = jsonObj[JsonKey::USER_ID].toString();
    m_password = jsonObj[JsonKey::PASSWORD].toString();
}


QJsonObject LoginRequestMessage::PackJsonData() const
{
    QJsonObject jsonObj;
    jsonObj[JsonKey::TYPE] = static_cast<int>(m_messageType);
    jsonObj[JsonKey::USER_ID] = m_userId;
    jsonObj[JsonKey::PASSWORD] = m_password;
    return jsonObj;
}

UserId LoginRequestMessage::getUserId() const
{
    return m_userId;
}


Password LoginRequestMessage::getPassword() const
{
    return m_password;
}


QString LoginRequestMessage::ToString()
{
    return this->m_userId + this->m_password;
}
